package com.sky.controller.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.entity.Orders;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminOrderController")
@RequestMapping("/admin/order")
@Slf4j
@Api(tags = "管理端-订单")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/conditionSearch")
    public Result<PageResult> pageAdmin(OrdersPageQueryDTO ordersPageQueryDTO){
        PageResult pageResult = orderService.pageAdmin(ordersPageQueryDTO);
        return Result.success(pageResult);
    }

    @GetMapping("/statistics")
    public Result<OrderStatisticsVO> selStatistics(){
        OrderStatisticsVO orderStatisticsVO = orderService.selStatistics();
        return Result.success(orderStatisticsVO);
    }

    @GetMapping("/details/{id}")
    public Result<OrderVO> selOrders(@PathVariable Long id){
        OrderVO orderVO = orderService.selOrders(id);
        return Result.success(orderVO);
    }
    @PutMapping("/confirm")
    public Result<String> upOdstatus(@RequestBody OrdersConfirmDTO ordersConfirmDTO){
        orderService.upOdtatus(ordersConfirmDTO);
        return Result.success();
    }

    @PutMapping("/rejection")
    public Result<String> puRejection(@RequestBody OrdersRejectionDTO ordersRejectionDTO){
        orderService.puRejection(ordersRejectionDTO);
        return Result.success();
    }

    @PutMapping("/cancel")
    public Result<String> upCancel(@RequestBody OrdersCancelDTO ordersCancelDTO){
        orderService.upCancel(ordersCancelDTO);
        return Result.success();
    }
    @PutMapping("/delivery/{id}")
    public Result<String> updeli(@PathVariable long id){
        orderService.updeli(id);
        return Result.success();
    }
    @PutMapping("/complete/{id}")
    public Result<String> upComplete(@PathVariable Long id){
        orderService.upComplete(id);
        return Result.success();
    }
}
